GBML manual / Strings

string_from_number

The older name of string: n written out as text. It still works and does exactly the same; new code can write string(n).

Syntax

string_from_number(n) -> string

Arguments

NameType
nreal

Returns

string

Description

This is the older name of string, and does exactly the same. It keeps working in every game; new code can write string(n).

n written out as text, for building a line of text around a number - converting a number to text.

For a number embedded directly in a message, $"score: {score}" template-string interpolation already does this for you. Reach for string_from_number instead when you need the number's text ON ITS OWN - to pass into string_join/string_replace, to compare, or to store.

Example

var score = 1200;
var score_text = string_from_number(score);
var line = string_join("FINAL SCORE ", score_text);

Uses the exact same conversion $"...{n}..." already does internally for a number, in a fixed 16-character buffer - large enough for any ordinary score/coordinate/timer; an extreme value can still be cut, the same as everywhere else in this group.

On the GBA

The same call as string, in the same fixed 16-character buffer.

See also: stringstring_to_numberstring_join